//
// Created by tacom on 22-9-6.
//

#ifndef CVCUDAIMPL_INTERSECTION_H
#define CVCUDAIMPL_INTERSECTION_H

#include "omp.h"
#include "iostream"
#include "vector"
#include "opencv2/opencv.hpp"

class intersection {
public:
    typedef std::pair<int, int> POINT;
    typedef std::vector<std::pair<int, int>> INTERSECTIONS;
    typedef std::vector<unsigned char> EACH_INTERSECTIONS;
    typedef std::vector<std::vector<unsigned char>> USABLE_INTERSECTIONS;

    INTERSECTIONS GetSkeletonIntersection(cv::Mat &skeleton);

private:
    EACH_INTERSECTIONS GetNeighbours(int x, int y, cv::Mat &img);
    const USABLE_INTERSECTIONS validIntersection = {
            {0, 1, 0, 1, 0, 0, 1, 0}, {0, 0, 1, 0, 1, 0, 0, 1}, {1, 0, 0, 1, 0, 1, 0, 0},
            {0, 1, 0, 0, 1, 0, 1, 0}, {0, 0, 1, 0, 0, 1, 0, 1}, {1, 0, 0, 1, 0, 0, 1, 0},
            {0, 1, 0, 0, 1, 0, 0, 1}, {1, 0, 1, 0, 0, 1, 0, 0}, {0, 1, 0, 0, 0, 1, 0, 1},
            {0, 1, 0, 1, 0, 0, 0, 1}, {0, 1, 0, 1, 0, 1, 0, 0}, {0, 0, 0, 1, 0, 1, 0, 1},
            {1, 0, 1, 0, 0, 0, 1, 0}, {1, 0, 1, 0, 1, 0, 0, 0}, {0, 0, 1, 0, 1, 0, 1, 0},
            {1, 0, 0, 0, 1, 0, 1, 0}, {1, 0, 0, 1, 1, 1, 0, 0}, {0, 0, 1, 0, 0, 1, 1, 1},
            {1, 1, 0, 0, 1, 0, 0, 1}, {0, 1, 1, 1, 0, 0, 1, 0}, {1, 0, 1, 1, 0, 0, 1, 0},
            {1, 0, 1, 0, 0, 1, 1, 0}, {1, 0, 1, 1, 0, 1, 1, 0}, {0, 1, 1, 0, 1, 0, 1, 1},
            {1, 1, 0, 1, 1, 0, 1, 0}, {1, 1, 0, 0, 1, 0, 1, 0}, {0, 1, 1, 0, 1, 0, 1, 0},
            {0, 0, 1, 0, 1, 0, 1, 1}, {1, 0, 0, 1, 1, 0, 1, 0}, {1, 0, 1, 0, 1, 1, 0, 1},
            {1, 0, 1, 0, 1, 1, 0, 0}, {1, 0, 1, 0, 1, 0, 0, 1}, {0, 1, 0, 0, 1, 0, 1, 1},
            {0, 1, 1, 0, 1, 0, 0, 1}, {1, 1, 0, 1, 0, 0, 1, 0}, {0, 1, 0, 1, 1, 0, 1, 0},
            {0, 0, 1, 0, 1, 1, 0, 1}, {1, 0, 1, 0, 0, 1, 0, 1}, {1, 0, 0, 1, 0, 1, 1, 0},
            {1, 0, 1, 1, 0, 1, 0, 0}
    };

};


#endif //CVCUDAIMPL_INTERSECTION_H
